package com.xyh.transaction.common;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum ImageType {

    GOODS("商品"), CATEGORY("类别"), BANNER("轮播图"), AVATAR("头像");

    private static final Map<String, ImageType> MAP = new HashMap<>();

    static {
        for (ImageType imageType : ImageType.values()) {
            MAP.put(imageType.getDetail(), imageType);
        }
    }

    private final String detail;

    ImageType(String detail) {
        this.detail = detail;
    }

    public static ImageType getByDetail(String detail) {
        ImageType imageType = MAP.get(detail);
        if (imageType == null) {
            throw new IllegalArgumentException("错误的图片类型: " + detail);
        }
        return imageType;
    }


}
